/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package demo1012;

import java.awt.Point;
import javax.swing.JOptionPane;

/**
 *
 * @author Administrator
 */
public class ExceptionDemo31 {

    public static void main(String args[]) {
        String s1 = JOptionPane.showInputDialog("input number");//"123"
        String s2 = JOptionPane.showInputDialog("input number");//"456"
        int div = 0;
        int flag = 0;

        try {
            int x1 = Integer.parseInt(s1);
            int x2 = Integer.parseInt(s2);
            div = x1 / x2;
        } catch (NumberFormatException e) {
            flag = 1;
        } catch (ArithmeticException e) {
            flag = 2;
        }
        if (flag == 0) {
            JOptionPane.showMessageDialog(null, div);
        } else if (flag == 1) {
            System.out.println("数字格式有问题");
        } else {
            System.out.println("除数为0");
        }

    }
}
